<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get last error code on the object</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="intlcalendar.getdayofweektype.html">« IntlCalendar::getDayOfWeekType</a></li>
      <li style="float: right;"><a href="intlcalendar.geterrormessage.html">IntlCalendar::getErrorMessage »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.intlcalendar.html">IntlCalendar</a></li>
    <li>Get last error code on the object</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="intlcalendar.geterrorcode" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">IntlCalendar::getErrorCode</h1>
  <h1 class="refname">intlcal_get_error_code</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.5.0, PHP 7, PHP 8, PECL &gt;= 3.0.0a1)</p><p class="refpurpose"><span class="refname">IntlCalendar::getErrorCode</span> -- <span class="refname">intlcal_get_error_code</span> &mdash; <span class="dc-title">Get last error code on the object</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-intlcalendar.geterrorcode-description">
  <h3 class="title">说明</h3>
  <p class="para">面向对象风格 (method):</p>
   <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>IntlCalendar::getErrorCode</strong></span>(): <span class="type"><span class="type">int</span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">过程化风格:</p>
  <div class="methodsynopsis dc-description"><span class="methodname"><strong>intlcal_get_error_code</strong></span>(<span class="methodparam"><span class="type"><a href="class.intlcalendar.html" class="type IntlCalendar">IntlCalendar</a></span> <code class="parameter">$calendar</code></span>): <span class="type"><span class="type">int</span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   Returns the numeric ICU error code for the last call on this object
   (including cloning) or the <span class="classname"><a href="class.intlcalendar.html" class="classname">IntlCalendar</a></span> given for
   the <code class="parameter">calendar</code> parameter (in the procedural‒style
   version). This may indicate only a warning (negative error code) or no
   error at all (<strong><code>U_ZERO_ERROR</code></strong>). The actual presence of an
   error can be tested with <span class="function"><a href="function.intl-is-failure.html" class="function">intl_is_failure()</a></span>.
  </p>
  <p class="para">
   Invalid arguments detected on the PHP side (before invoking functions of the
   ICU library) are not recorded for the purposes of this function.
  </p>
  <p class="para">
   The last error that occurred in any call to a function of the intl
   extension, including early argument errors, can be obtained with
   <span class="function"><a href="function.intl-get-error-code.html" class="function">intl_get_error_code()</a></span>. This function resets the global
   error code, but not the objectʼs error code.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-intlcalendar.geterrorcode-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">calendar</code></dt>

    <dd>

     <p class="para">
      The calendar object, on the procedural style interface.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-intlcalendar.geterrorcode-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   An ICU error code indicating either success, failure or a warning.
   Returns <strong><code>false</code></strong> on failure.
  </p>
 </div>



 <div class="refsect1 examples" id="refsect1-intlcalendar.geterrorcode-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2397">
   <p><strong>示例 #1 <span class="function"><strong>IntlCalendar::getErrorCode()</strong></span> and
   <span class="function"><a href="intlcalendar.geterrormessage.html" class="function">IntlCalendar::getErrorMessage()</a></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />ini_set</span><span style="color: #007700">(</span><span style="color: #DD0000">"intl.error_level"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">E_WARNING</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ini_set</span><span style="color: #007700">(</span><span style="color: #DD0000">"intl.default_locale"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"nl"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$intlcal&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">IntlGregorianCalendar</span><span style="color: #007700">(</span><span style="color: #0000BB">2012</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">29</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$intlcal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getErrorCode</span><span style="color: #007700">(),<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$intlcal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getErrorMessage</span><span style="color: #007700">()<br />);<br /></span><span style="color: #0000BB">$intlcal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">fieldDifference</span><span style="color: #007700">(-</span><span style="color: #0000BB">1e100</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">IntlCalendar</span><span style="color: #007700">::</span><span style="color: #0000BB">FIELD_SECOND</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$intlcal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getErrorCode</span><span style="color: #007700">(),<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$intlcal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getErrorMessage</span><span style="color: #007700">()<br />);</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
int(0)
string(12) &quot;U_ZERO_ERROR&quot;

Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in /home/glopes/php/ws/example.php on line 10
int(1)
string(81) &quot;intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR&quot;
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-intlcalendar.geterrorcode-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="intlcalendar.geterrormessage.html" class="methodname" rel="rdfs-seeAlso">IntlCalendar::getErrorMessage()</a> - Get last error message on the object</span></li>
    <li class="member"><span class="methodname"><a href="function.intl-is-failure.html" class="methodname" rel="rdfs-seeAlso">intl_is_failure()</a> - Check whether the given error code indicates failure</span></li>
    <li class="member"><span class="methodname"><a href="function.intl-error-name.html" class="methodname" rel="rdfs-seeAlso">intl_error_name()</a> - Get symbolic name for a given error code</span></li>
    <li class="member"><span class="methodname"><a href="function.intl-get-error-code.html" class="methodname" rel="rdfs-seeAlso">intl_get_error_code()</a> - Get the last error code</span></li>
    <li class="member"><span class="methodname"><a href="function.intl-get-error-message.html" class="methodname" rel="rdfs-seeAlso">intl_get_error_message()</a> - Get description of the last error</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>